echarts用android实现以及rem适配手机端方法(react |
您所在的位置:网站首页 › react native chart › echarts用android实现以及rem适配手机端方法(react |
2022-12-23
ECharts
var d = document.documentElement;
var cw = d.clientWidth || 750;
document.documentElement.style.fontSize = (cw/750 * 100) + 'px';
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('main'));
function remToPx(rem) {
var fontSize = document.documentElement.style.fontSize;
return Math.floor(rem * fontSize.replace('px', ''));
}
// 指定图表的配置项和数据
var option = {
tooltip: {
trigger: 'item',
formatter: "{a} {b}: {c} ({d}%)"
},
series: [
{
name:'访问来源',
type:'pie',
selectedMode: 'single',
radius: [0, '45%'],
center: ['50%', '49%'],
label: {
normal: {
position: 'inner',
textStyle : {
fontWeight : 'normal',
fontSize : '0.18rem',
}
}
},
labelLine: {
normal: {
show: false
}
},
data: [
{value:335, name:'A', selected:true},
{value:309, name:'B'},
],
},
{
name:'访问来源',
type:'pie',
radius: ['60%', '80%'],
center: ['50%', '49%'],
label: {
normal: {
backgroundColor: '#eee',
borderColor: '#aaa',
rich: {
a: {
color: '#999',
lineHeight: remToPx(0.22),
align: 'center'
},
hr: {
borderColor: '#aaa',
width: '100%',
borderWidth: 1,
height: 0
},
b: {
fontSize: '0.32rem',
lineHeight: '0.66rem',
},
per: {
color: '#eee',
backgroundColor: '#334455',
padding: ['0.04rem', '0.08rem'],
borderRadius: '0.04rem'
}
}
}
},
data: [
{value:235, name:'A'},
{value:100, name:'B'},
{value:209, name:'A'},
{value:100, name:'B'},
],
}
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
相关文章: 移动端 rem适配方法 2022-12-23 『REM』手机屏幕适配 2022-12-23 rem 移动端适配 2022-02-09 rem移动端适配 2022-12-23 移动端适配 rem 2022-12-23 移动端rem适配 2022-12-23 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |